package com.zhong.service;

import com.zhong.dao.EmpDao;
import com.zhong.po.Emp;
import com.zhong.po.EmpExample;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service      //标识该类为业务层
//@Transactional(isolation= Isolation.REPEATABLE_READ     //isolation: 隔离级别
//        ,propagation = Propagation.REQUIRED             //propagation： 传播级别
//        ,rollbackFor = Exception.class                  //rollbackFor: 当发生Exception异常的时候，事务进行回滚
//        ,readOnly = true,                               //设置只读事务
//        timeout = 1000)
public class EmpServiceImpl implements EmpService {

    @Autowired  //自动注入 DI
    private EmpDao empDao;

    //新增
    public String insertSelective(Emp emp) {
        empDao.insertSelective(emp);
        return "ok";
    }

    //删除  回滚  spring事务  db事务
//    @Transactional(isolation= Isolation.REPEATABLE_READ     //isolation: 隔离级别
//            ,propagation = Propagation.REQUIRED             //propagation： 传播行为
//            ,rollbackFor = Exception.class                  //rollbackFor: 当发生Exception异常的时候，事务进行回滚
//            ,readOnly = true,                               //设置只读事务
//            timeout = 1000)                                 //设置超时时间
    public String deleteByPrimaryKey(int id) {
        empDao.deleteByPrimaryKey(id);
        int i = 0/0;
        return "ok";
    }

}
